Appendix
How-to Example - Setting a default Effectivity Scope in “Effectivity Criteria Filter” dialog
This section discusses an approach to set a default Effectivity Scope on the Effectivity Criteria dialog with the corresponding variables based on the default scope.
There can be a variety of business rules to determine the default effectivity scope, such as item classification, item state, user identities, and teams. It may be necessary to pre-populate the Effectivity scope only if a single effectivity scope can be determined. In addition, business-specific logic may change over time.
It is ideal to have a single place where all default rule logic is defined/implemented and retrieved. A server-side method – with parameters as needed – will be an entry point for querying a default effectivity scope. The results can be cached across many requests. This server method can be called from either the client or server-side as shown in the following figure.
Figure 56.
For the new server-side method to identify a default effectivity scope:
-
A new server-side method is created and given a name such as effs_getScopeDefaults. This name is abstract enough to expand the method’s functionality as needed. For example, the method can return not only a default scope, but also default values for variables in that scope.
-
The method can return a JSON string. The format may look like:
{
"scope": {
"id": "32-hex-id"
}
}
The value of the scope.id property is the item ID of the effectivity scope item (effs_scope ItemType).
This format provides flexibility to consider future improvements with minimal to no changes.
-
The method may accept parameters, as needed, for processing of the business logic.
As for the client-side changes to the Effectivity Criteria dialog, the current order of events is outlined as shown in Figure 57.
Figure 57.
Requesting the default scope from the server and passing that information along to the Effectivity Criteria dialog to be displayed requires the following modification:
Figure 58.
The changes outlined in the previous figure can be accomplished with the following:
-
In the effs_setEffectivityCriteriaHandl client-side method, make a request to the new server-side method to get default scope details. A client-side request to a server-side method can be achieved using aras.applyMethod('effs_getScopeDefaults',’’);
-
Construct an object from the response string that would be expected in the dialog EffectivityCriteriaDialog’s constructor (modifications in the constructor would be a next step). You can create an object from a string using JSON.parse().
-
Take the ‘scope’ property from the just constructed object and pass it as a new additional argument to EffectivityCriteriaDialog’s object creation in the effs_setEffectivityCriteriaHandl client-side method.
-
After the changes from the steps outlined above, the effs_setEffectivityCriteriaHandl client-side method will look similar to the following:
Figure 59.
-
Open the following file: Innovator/Client/Modules/aras.innovator.core.EffectivityServices/Scripts/EffectivityCriteriaDialog.js
Update the EffectivityCriteriaDialog’s constructor to process the new parameter. To pre-populate the scope field on the dialog form, add the this.scope.id property in the constructor. The resulting constructor may look like the following:
Figure 60.